package com.splic.product.service.impl;

import java.util.Date;
import java.util.List;
import com.splic.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.splic.product.mapper.UserMotionRankingProvinceMapper;
import com.splic.product.domain.UserMotionRankingProvince;
import com.splic.product.service.UserMotionRankingProvinceService;
import org.springframework.transaction.annotation.Transactional;

/**
 * 用户运动量省份排名统计Service业务层处理
 * 
 * @author singe
 * @date 2022-02-16
 */
@Service
public class UserMotionRankingProvinceServiceImpl implements UserMotionRankingProvinceService
{
    @Autowired
    private UserMotionRankingProvinceMapper userMotionRankingProvinceMapper;

    /**
     * 查询用户运动量省份排名统计
     * 
     * @param id 用户运动量省份排名统计主键
     * @return 用户运动量省份排名统计
     */
    @Override
    public UserMotionRankingProvince selectUserMotionRankingProvinceById(Long id)
    {
        return userMotionRankingProvinceMapper.selectUserMotionRankingProvinceById(id);
    }

    /**
     * 查询用户运动量省份排名统计列表
     * 
     * @param userMotionRankingProvince 用户运动量省份排名统计
     * @return 用户运动量省份排名统计
     */
    @Override
    public List<UserMotionRankingProvince> selectPageList(UserMotionRankingProvince userMotionRankingProvince)
    {
        return userMotionRankingProvinceMapper.selectUserMotionRankingProvinceList(userMotionRankingProvince);
    }

    /**
     * 查询用户运动量省份排名统计列表
     *
     * @param userMotionRankingProvince 用户运动量省份排名统计
     * @return 用户运动量省份排名统计
     */
    @Override
    public List<UserMotionRankingProvince> selectUserMotionRankingProvinceList(UserMotionRankingProvince userMotionRankingProvince)
    {
        return userMotionRankingProvinceMapper.selectUserMotionRankingProvinceList(userMotionRankingProvince);
    }

    /**
     * 新增用户运动量省份排名统计
     * 
     * @param userMotionRankingProvince 用户运动量省份排名统计
     * @return 结果
     */
    @Override
    public int insert(UserMotionRankingProvince userMotionRankingProvince)
    {
        userMotionRankingProvince.setCreateTime(DateUtils.getNowDate());
        return userMotionRankingProvinceMapper.insert(userMotionRankingProvince);
    }

    /**
     * 修改用户运动量省份排名统计
     * 
     * @param userMotionRankingProvince 用户运动量省份排名统计
     * @return 结果
     */
    @Override
    public int update(UserMotionRankingProvince userMotionRankingProvince)
    {
        userMotionRankingProvince.setUpdateTime(DateUtils.getNowDate());
        return userMotionRankingProvinceMapper.update(userMotionRankingProvince);
    }


    /**
     * 删除用户运动量省份排名统计信息
     * 
     * @param id 用户运动量省份排名统计主键
     * @return 结果
     */
    @Override
    public int deleteById(Long id)
    {
        return userMotionRankingProvinceMapper.deleteById(id);
    }
    /**
     * 修改用户运动量省份排名统计
     *
     * @param userMotionRankingProvince 用户运动量省份排名统计信息
     * @return 结果
     */
    @Override
    @Transactional
    public int saveOrUpdate(UserMotionRankingProvince userMotionRankingProvince)
    {
        if(userMotionRankingProvince.getId() != null){
            userMotionRankingProvince.setUpdateTime(new Date());
            return userMotionRankingProvinceMapper.update(userMotionRankingProvince);
        }else{
            userMotionRankingProvince.setCreateTime(new Date());
            return userMotionRankingProvinceMapper.insert(userMotionRankingProvince);
        }
    }
}
